package org.example;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class T1 {
    @Test
    public void T() throws IOException {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        List<Dept> selectDept = sqlSession.selectList("selectDept");
//        System.out.println(selectDept);
        for (Dept dept : selectDept) {
            System.out.println(dept.getDeptino()+"\t"+dept.getDname()+"\t"+dept.getLoc());
        }
    }
}
